package com.miraeasset.www.sitemap;

import java.io.InputStream;
import java.util.List;

public class SiteMap {
	public SiteMap(InputStream docStream){
		this.doc = new SiteMapDoc(docStream);
	}
	public String render(String requestUri)
	{
		String renderedString = "";
		List<SiteMapNode> history_list = doc.getHistory(requestUri);
		for(int i=0; i < history_list.size(); i++){
			int last_item_index = i + 1;
			boolean isLastItem = history_list.size() == last_item_index;
			if(isLastItem)
				renderedString += history_list.get(i).render(isLastItem);	
			else
				renderedString += history_list.get(i).render(isLastItem) + divideString;
		}
		return renderedString;
	}

	private SiteMapDoc doc;
	private String divideString = "&gt;";
	
	public String getDivideString() {
		return divideString;
	}
	public void setDivideString(String divideString) {
		this.divideString = divideString;
	}
}